#ifndef __HAL_FLOW_H
#define __HAL_FLOW_H

#include "main.h"

#define LOST_WATER_TIME 120

typedef struct
{
	uint64_t tickStart;//流量开始计时
	uint64_t tickEnd;//流量结束计时
	uint32_t tickCnt;//流量脉冲累计个数
	uint32_t flow_ml;//累计净水 mL
	uint32_t flowPer;//净水流量 mL/min
	uint32_t ctrlFlowPer;//用于通知控制板的平均流量值
	//以下用于自吸D1流量计告警
	uint32_t error;//流量故障标记
	uint16_t errorFlowBuff[LOST_WATER_TIME];//2分钟内平均流量
	uint16_t errorFlowBuffIndex;//buffIndex
	uint32_t errorFlowCnt;//每s的平均计数值
	uint8_t  lackOfWaterCnt;//缺水计数
	uint32_t timeCnt;//时间累计
	uint32_t saveTickCnt;
}tsTypeFlowInfo;

extern tsTypeFlowInfo gFlowInfo;
void OnInitFlow(void);
uint8_t OnCheckFlowValue(uint32_t makingcnt);
uint8_t OnCheckFlowPerSecend(void);
uint32_t OnGetFlowValue(uint32_t totalcnt, uint32_t second);


#endif

